<?php

/**
 * ControlService class
 *
 * Service routine:
 * WSDL parser
 * Call the remote service method
 *
 * @name ControlService
 *
 **/

class ControlService
{
    private $url;
    private $service;

    public function __construct($url)
    {
        $this->url = $url;

        try
        {
            $this->getService();
        }
        catch (Exception $e)
        {
            throw new Exception($e->getMessage());
        }
    }

    private function getService()
    {
        $this->service = @new SoapClient($this->url);
    }

    public function __call($method, $args = array())
    {
        try
        {
            /*foreach ($args as &$arg)
            {
                if (!is_numeric($arg))
                {
                    $arg = serialize($arg);
                }
            }*/

            //return unserialize(call_user_func_array(array($this->service, $method), $args));
            return call_user_func_array(array($this->service, $method), $args);
        }
        catch (Exception $e)
        {
            throw new Exception($e->getMessage());
        }
    }

}

?>